import { BaseEntity, Entity, Column, PrimaryGeneratedColumn, CreateDateColumn,
    UpdateDateColumn, JoinColumn, ManyToOne } from "typeorm";
import { Category } from "./category";

@Entity({ name: "posts" })
export class Post extends BaseEntity {
    @PrimaryGeneratedColumn()
    id: number;

    @ManyToOne(() => Category)
    @JoinColumn({ name: "category_id" })
    category: Category;

    @Column()
    title: string;

    @Column({
        length: 10000
    })
    content: string;

    @Column()
    desc: string;

    @CreateDateColumn({ name: "created_at" })
    createdAt: number;

    @UpdateDateColumn({ name: "updated_at" })
    updatedAt: number;
}